// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios'

/* @desc:httpInterceptor */
import {request,response} from './service/httpInterceptor'
axios.interceptors.request.use(request)
axios.interceptors.response.use(response);


import store from './vuex/index'

/* base style */
import '../static/lib/css/base.scss'

/*ElementUI*/
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)
/*filter*/
import filter from './plugin/filter'
Vue.use(filter)

/*method*/
import pluginMethod from './plugin/method'
Vue.use(pluginMethod)
/*component*/
import component from './plugin/component'
Vue.use(component)
import VueLazyLoad from 'vue-lazyload'
Vue.use(VueLazyLoad,{
	error:require('./../static/img/loading-err.png'),
	loading:require('./../static/img/loading.gif')
})
//测试写死的session
// sessionStorage.setItem("username",'67e3b91ba765922ac53f04fa52e32b9f')
// sessionStorage.setItem("u_id",'7')

router.beforeEach(function (to, from, next) {
  if (to.meta && to.meta.title){
    document.title = to.meta.title;
  } 
  if(to.name != 'Login'){
    if(sessionStorage.getItem('username')){  
      next();
    }else{  
      next({ path: '/Login' });
    }
  }else{
    next();
  } 
});


import  VueQuillEditor from 'vue-quill-editor'
// require styles 引入样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor)

Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
